home *** CD-ROM | disk | FTP | other *** search
- package netscape.util;
-
- import java.io.EOFException;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.UTFDataFormatException;
-
- public class CompactInputStream extends InputStream {
- static final int INVALID_BUFFER_COUNT = 8;
- // $FF: renamed from: in java.io.InputStream
- InputStream field_0;
- int booleanCount = 8;
- int booleanBuffer;
- Vector stringVector = new Vector(128);
-
- public CompactInputStream(InputStream var1) {
- this.field_0 = var1;
- }
-
- public int read() throws IOException {
- this.booleanCount = 8;
- return this.field_0.read();
- }
-
- public int read(byte[] var1) throws IOException {
- this.booleanCount = 8;
- return this.field_0.read(var1, 0, var1.length);
- }
-
- public int read(byte[] var1, int var2, int var3) throws IOException {
- this.booleanCount = 8;
- return this.field_0.read(var1, var2, var3);
- }
-
- public long skip(long var1) throws IOException {
- if (var1 > 0L) {
- this.booleanCount = 8;
- return this.field_0.skip(var1);
- } else {
- return var1;
- }
- }
-
- public int available() throws IOException {
- return this.field_0.available();
- }
-
- public void close() throws IOException {
- this.booleanCount = 8;
- this.field_0.close();
- }
-
- public void mark(int var1) {
- }
-
- public void reset() throws IOException {
- throw new IOException("mark/reset not supported");
- }
-
- public boolean markSupported() {
- return false;
- }
-
- public void readFully(byte[] var1) throws IOException {
- this.readFully(var1, 0, var1.length);
- }
-
- public void readFully(byte[] var1, int var2, int var3) throws IOException {
- this.booleanCount = 8;
- InputStream var6 = this.field_0;
-
- int var5;
- for(int var4 = 0; var4 < var3; var4 += var5) {
- var5 = var6.read(var1, var2 + var4, var3 - var4);
- if (var5 < 0) {
- throw new EOFException();
- }
- }
-
- }
-
- public int skipBytes(int var1) throws IOException {
- int var2;
- for(var2 = var1; var1 > 0; var1 = (int)((long)var1 - this.skip((long)var1))) {
- }
-
- return var2;
- }
-
- public boolean readCompactBoolean() throws IOException {
- int var2 = this.booleanBuffer;
- int var3 = this.booleanCount;
- if (var3 >= 8) {
- var2 = this.field_0.read();
- if (var2 < 0) {
- throw new EOFException();
- }
-
- var3 = 0;
- }
-
- boolean var1 = (var2 & 1 << var3) != 0;
- ++var3;
- this.booleanBuffer = var2;
- this.booleanCount = var3;
- return var1;
- }
-
- public boolean readBoolean() throws IOException {
- this.booleanCount = 8;
- int var1 = this.field_0.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return var1 != 0;
- }
- }
-
- public byte readByte() throws IOException {
- this.booleanCount = 8;
- int var1 = this.field_0.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return (byte)var1;
- }
- }
-
- public int readUnsignedByte() throws IOException {
- this.booleanCount = 8;
- int var1 = this.field_0.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return var1;
- }
- }
-
- public short readShort() throws IOException {
- this.booleanCount = 8;
- InputStream var1 = this.field_0;
- int var2 = var1.read();
- int var3 = var1.read();
- if ((var2 | var3) < 0) {
- throw new EOFException();
- } else {
- return (short)((var2 << 8) + var3);
- }
- }
-
- public int readUnsignedShort() throws IOException {
- this.booleanCount = 8;
- InputStream var1 = this.field_0;
- int var2 = var1.read();
- int var3 = var1.read();
- if ((var2 | var3) < 0) {
- throw new EOFException();
- } else {
- return (var2 << 8) + var3;
- }
- }
-
- public char readChar() throws IOException {
- this.booleanCount = 8;
- InputStream var1 = this.field_0;
- int var2 = var1.read();
- int var3 = var1.read();
- if ((var2 | var3) < 0) {
- throw new EOFException();
- } else {
- return (char)((var2 << 8) + var3);
- }
- }
-
- public int readCompactInt() throws IOException {
- this.booleanCount = 8;
- InputStream var1 = this.field_0;
- int var2 = var1.read();
- if (var2 < 0) {
- throw new EOFException();
- } else if (var2 == 64) {
- return Integer.MIN_VALUE;
- } else {
- boolean var4 = (var2 & 64) != 0;
- int var3 = var2 & 63;
- if ((var2 & 128) != 0) {
- var2 = var1.read();
- if (var2 < 0) {
- throw new EOFException();
- }
-
- var3 |= (var2 & 127) << 6;
- if ((var2 & 128) != 0) {
- var2 = var1.read();
- if (var2 < 0) {
- throw new EOFException();
- }
-
- var3 |= (var2 & 127) << 13;
- if ((var2 & 128) != 0) {
- var2 = var1.read();
- if (var2 < 0) {
- throw new EOFException();
- }
-
- var3 |= (var2 & 127) << 20;
- if ((var2 & 128) != 0) {
- var2 = var1.read();
- if (var2 < 0) {
- throw new EOFException();
- }
-
- var3 |= (var2 & 127) << 27;
- }
- }
- }
- }
-
- if (var4) {
- var3 = -var3;
- }
-
- return var3;
- }
- }
-
- public int readInt() throws IOException {
- this.booleanCount = 8;
- InputStream var1 = this.field_0;
- int var2 = var1.read();
- int var3 = var1.read();
- int var4 = var1.read();
- int var5 = var1.read();
- if ((var2 | var3 | var4 | var5) < 0) {
- throw new EOFException();
- } else {
- return (var2 << 24) + (var3 << 16) + (var4 << 8) + var5;
- }
- }
-
- public long readLong() throws IOException {
- return ((long)this.readInt() << 32) + ((long)this.readInt() & 4294967295L);
- }
-
- public float readFloat() throws IOException {
- return Float.intBitsToFloat(this.readInt());
- }
-
- public double readDouble() throws IOException {
- return Double.longBitsToDouble(this.readLong());
- }
-
- public String readCompactUTF() throws IOException {
- int var1 = this.readCompactInt();
- if (var1 == 0) {
- return null;
- } else if (var1 == 1) {
- return "";
- } else if (var1 < 0) {
- String var2 = this.readUTFBytes(-var1);
- this.stringVector.addElement(var2);
- return var2;
- } else {
- return (String)this.stringVector.elementAt(var1 - 2);
- }
- }
-
- public String readUTF() throws IOException {
- int var1 = this.readUnsignedShort();
- return var1 == 65535 ? null : this.readUTFBytes(var1);
- }
-
- private final String readUTFBytes(int var1) throws IOException {
- this.booleanCount = 8;
- char[] var2 = new char[var1];
- int var3 = 0;
- int var4 = 0;
-
- while(var3 < var1) {
- int var5 = this.readUnsignedByte();
- switch (var5 >> 4) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- ++var3;
- var2[var4++] = (char)var5;
- break;
- case 12:
- case 13:
- var3 += 2;
- if (var3 > var1) {
- throw new UTFDataFormatException();
- }
-
- int var10 = this.readUnsignedByte();
- if ((var10 & 192) != 128) {
- throw new UTFDataFormatException();
- }
-
- var2[var4++] = (char)((var5 & 31) << 6 | var10 & 63);
- break;
- case 14:
- var3 += 3;
- if (var3 > var1) {
- throw new UTFDataFormatException();
- }
-
- int var6 = this.readUnsignedByte();
- int var7 = this.readUnsignedByte();
- if ((var6 & 192) != 128 || (var7 & 192) != 128) {
- throw new UTFDataFormatException();
- }
-
- var2[var4++] = (char)((var5 & 15) << 12 | (var6 & 63) << 6 | var7 & 63);
- case 8:
- case 9:
- case 10:
- case 11:
- default:
- throw new UTFDataFormatException();
- }
- }
-
- return new String(var2, 0, var4);
- }
- }
-